/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package petstore.model;

import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Entity class HistoricoSenha
 * 
 * @author Tom Hayden
 */
@Entity
@Table(name = "historico_senha")
@AttributeOverride(name="id", column=@Column(name="cdhistoricosenha"))
@NamedQueries( {
    @NamedQuery(name="HistoricoSenha.checkPasswordInHistory", 
                query="SELECT h " +
                      "FROM HistoricoSenha h " +
                      "JOIN h.usuario u " +
                      "WHERE u.senha = :senha " +
                      "OR h.senhaAnterior = :senha")
})
public class HistoricoSenha extends BusinessObject {

    @Column(name = "dtinchistorico")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dataInclusao;
    
    @Column(name = "senhaanterior")
    private String senhaAnterior;
    
    @Column(name = "ativo")
    private boolean active;
    
    @ManyToOne
    @JoinColumn(name="cdusuario")
    private Usuario usuario;
    
    /** Creates a new instance of HistoricoSenha */
    public HistoricoSenha() {
        this.active = true;
    }

    public Date getDataInclusao() {
        return dataInclusao;
    }

    public void setDataInclusao(Date dataInclusao) {
        this.dataInclusao = dataInclusao;
    }

    public String getSenhaAnterior() {
        return senhaAnterior;
    }

    public void setSenhaAnterior(String senhaAnterior) {
        this.senhaAnterior = senhaAnterior;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

}
